package struts.ext.returntype.handler;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForward;

import struts.ext.util.Jsons;

public class JsonHandler implements Handler {

	@Override
	public ActionForward handle(HttpServletRequest request, HttpServletResponse response, Object retValue) {
		response.setContentType("text/json;charset=UTF-8");
    	try {
			response.getWriter().write(Jsons.toJson(retValue ));
		} catch (IOException e) {
			
			e.printStackTrace();
		}
		return null;
	}

}
